package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.AttendanceReplace;
import com.dragon.repository.entity.OtherFile;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class AttendanceReplaceVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "补卡原因1：上班补卡2：下班补卡")
    private Integer replaceType;

    @ApiModelProperty(value = "补卡时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date replaceTime;

    @ApiModelProperty(value = "补卡事由")
    private String replaceCase;

    @ApiModelProperty(value = "附件")
    private List<OtherFile> otherFiles;

    @ApiModelProperty(value = "用户id")
    private Integer adminId;

    @ApiModelProperty(value = "状态：0 待审核 1审核通过 2审核不通过 3作废 4删除")
    private Integer status;

    @ApiModelProperty(value = "考勤子表id")
    private Integer attendanceChildId;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static AttendanceReplace convert(AttendanceReplaceVO vo) {
        AttendanceReplace entity = new AttendanceReplace();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<AttendanceReplace> convertList(List<AttendanceReplaceVO> list) {
        List<AttendanceReplace> resultList = new ArrayList<>();
        for (AttendanceReplaceVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
